package com.奇技淫巧;

import java.lang.reflect.Field;

public class FinalTest {


    public final String strX;

    private final int intX;

    private final Object objX;

    public FinalTest(String strX, int intX, Object objX) {
        this.strX = strX;
        this.intX = intX;
        this.objX = objX;
    }

    public String getStrX() {
        return strX;
    }

    public int getIntX() {
        return intX;
    }

    public Object getObjX() {
        return objX;
    }

    public static void main(String[] args) throws Exception {
        FinalTest finalTest = new FinalTest("strX",1, new StringBuffer("objX"));
        System.out.println(finalTest.getStrX());
        System.out.println(finalTest.getIntX());
        System.out.println(finalTest.getObjX());

        //Field field = finalTest.getClass().getDeclaredField("strX");
        Field field = finalTest.getClass().getField("strX");
        //field.setAccessible(true);
        field.set(finalTest,"stringX");
        System.out.println(finalTest.getStrX());
    }

}
